﻿#include "pch.h"

CBaseWrapper::CBaseWrapper()
{
    memset(this, 0, sizeof(CBaseWrapper));
}

// sub_10025190
int32_t CBaseWrapper::getNum()
{
    return *this->num;
};

// unknown_libname_16
LPVOID CBaseWrapper::getHead()
{
    return this->head;
};

// unknown_libname_11
int32_t *CBaseWrapper::getNumPointer()
{
    return this->num;
};

// // unknown_libname_17
int32_t CBaseWrapper::getLen()
{
    return this->len;
};

// 1001E000
int32_t *CBaseWrapper::clearHead()
{
    int32_t *result;

    memset(this->head, 0, this->size * this->len);
    result = this->num;
    *result = 0;
    this->tail = 0;
    return result;
};

// sub_1001D320
void *CBaseWrapper::close(char flag)
{
    this->close_();
    if (flag & 1)
    {
        delete this;
        return NULL;
    }
    return this;
};

// sub_1001D640
CBaseWrapper *CBaseWrapper::close_()
{
    return this->freeHead();
};

// sub_1001DEB0
CBaseWrapper *CBaseWrapper::freeHead()
{
    if (this->needFreeHead)
    {
        if (this->head)
        {
            delete[] (int32_t *)this->head;
        }
        this->head = NULL;
        this->len = 0;
        *(this->num) = 0;
    }
    return this;
};

// sub_1001E2E0
int32_t CBaseWrapper::setTail(int32_t idx)
{
    int32_t result;

    if (idx < 0 || idx > (*this->num) - 1)
    {
        if (idx >= *(this->num))
        {
            this->tail = *(this->num);
        }
        result = false;
    }
    else
    {
        this->tail = idx;
        result = true;
    }
    return result;
}
